import java.util.Scanner;

/**
 * @Author: YCKOKO
 * @Date: 2023-05-14
 * @Time:11:57
 * @Description:
 */
public class demo2 {
    public static int StrToInt(String str) {
        if(str.isEmpty()){
            return 0;
        }
        int ret = 0;
        if(str.charAt(0)=='+' || str.charAt(0)=='-'){
            for(int i = 1; i < str.length(); i++){
                int num = str.charAt(i)-'0';
                if(num < 0 || num > 9){
                    return 0;
                }
            }
            for(int i = 1; i < str.length(); i++){
                int num = str.charAt(i)-'0';
                ret = ret*10 + num;
            }
            if(str.charAt(0) == '-'){
                ret = -1 * ret;
            }
            return ret;
        }else{
            for (int i = 0; i < str.length(); i++) {
                int num = str.charAt(i)-'0';
                if(num < 0 || num > 9){
                    return 0;
                }
            }
            for(int i = 0; i < str.length(); i++){
                int num = str.charAt(i)-'0';
                ret = ret*10 + num;
            }
            return ret;
        }
    }
}
